#include "flip_internal.h"

int luaflip_quad(lua_State* L)
{
	luaflip_data* data = global_data(L);
	double v[8];
	v[0] = luaL_checknumber(L, 1);
	v[1] = luaL_checknumber(L, 2);
	v[2] = luaL_checknumber(L, 3);
	v[3] = luaL_checknumber(L, 4);
	v[4] = luaL_checknumber(L, 5);
	v[5] = luaL_checknumber(L, 6);
	v[6] = luaL_checknumber(L, 7);
	v[7] = luaL_checknumber(L, 8);
	
	flip_draw_quad(&data->draw_buffer,
		(float)v[0], (float)v[1], (float)v[2], (float)v[3], 
		(float)v[4], (float)v[5], (float)v[6], (float)v[7]);
	
	return 0;
}

int luaflip_clear(lua_State* L)
{
	luaflip_data* data = global_data(L);
	flip_draw_clear(&data->draw_buffer);
	return 0;
}

int luaflip_color(lua_State* L)
{
	luaflip_data* data = global_data(L);
	double r = luaL_checknumber(L, 1);
	double g = luaL_checknumber(L, 2);
	double b = luaL_checknumber(L, 3);
	
	flip_draw_color(&data->draw_buffer, (float)r, (float)g, (float)b);
	return 0;
}
